package com.kmust.dream.wanderingdream.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kmust.dream.wanderingdream.comm.pojo.ResultBean;
import com.kmust.dream.wanderingdream.product.entity.ProductPropertyValue;
import com.kmust.dream.wanderingdream.product.service.ProductPropertyValueService;
import com.kmust.dream.wanderingdream.product.mapper.ProductPropertyValueMapper;
import com.kmust.dream.wanderingdream.product.utils.ReturnUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 */
@Service
@Transactional
public class ProductPropertyValueServiceImpl extends ServiceImpl<ProductPropertyValueMapper, ProductPropertyValue>
implements ProductPropertyValueService{

    @Override
    public ResultBean getProductPropertyValueById(Integer valueId) {
        return ReturnUtils.getOne(this.getById(valueId));
    }

    @Override
    public ResultBean getProductPropertyValueByNameById(Integer nameId) {
        return ReturnUtils.getList(this.list(new QueryWrapper<ProductPropertyValue>().eq("product_property_name_id",nameId)));
    }

    @Override
    public ResultBean getPropertyValues() {
        return ReturnUtils.getList(this.list());
    }

    @Override
    public ResultBean addPropertyValue(ProductPropertyValue productPropertyValue) {
        return ReturnUtils.add(this.save(productPropertyValue));
    }

    @Override
    public ResultBean updatePropertyValue(ProductPropertyValue productPropertyValue) {
        return ReturnUtils.update(this.updateById(productPropertyValue));
    }

    @Override
    public ResultBean deletePropertyValue(Integer valueId) {
        return ReturnUtils.delete(this.removeById(valueId));
    }
}




